package com.yequan.thread.threadpool.base;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @author : Administrator
 * @date : 2020/10/6
 */
public class TestThreadPool {
    private static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5);
    private static ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
    private static ExecutorService singleThreadPool = Executors.newSingleThreadExecutor();
    private static ExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(5);

    public static void main(String[] args) {

    }

    private static void testFixedThreadPool() {
        for (int i = 0; i < 10; i++) {
            fixedThreadPool.submit(new Runnable() {
                @Override
                public void run() {
                    try {
                        TimeUnit.SECONDS.sleep(5);

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }

    private static void testCachedThreadPool() {

    }

    private static void testSingleThreadPool() {

    }

    private static void testScheduledThreadPool() {

    }

}
